www.gusucode.com > VC 模范QQ做的一个界面-源码程序 > VC 模范QQ做的一个界面-源码程序/code/MyQQ/MyQQDlg.cpp

    //Download by http://www.NewXing.com
// MyQQDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MyQQ.h"
#include "MyQQDlg.h"
#include "winuser.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define NEAR_SIZE	4
#define APPEAR_SIZE 3
#define SCREEN_CX	(::GetSystemMetrics(SM_CXSCREEN))

enum{
		MS_Normal = 0,
		MS_Hover,
		MS_LBDown
};

enum{
		ALIGN_NONE,
		ALIGN_TOP,
		ALIGN_LEFT,
		ALIGN_RIGHT
};
UINT	AlignType = ALIGN_NONE;
extern  CMagneticClass MagneticObj;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyQQDlg dialog

CMyQQDlg::CMyQQDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMyQQDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMyQQDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_nCount = 0;
	m_MouseState = MS_Normal;
	m_CapBnIndex = 0;
}

void CMyQQDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyQQDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyQQDlg, CDialog)
	//{{AFX_MSG_MAP(CMyQQDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_SIZE()
	ON_WM_NCPAINT()
	ON_WM_MOVING()
	ON_WM_NCMOUSEMOVE()
	ON_WM_TIMER()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	ON_WM_NCACTIVATE()
	ON_WM_NCCALCSIZE()
	ON_WM_ACTIVATE()
	ON_WM_CREATE()
	ON_WM_NCLBUTTONDOWN()
	ON_WM_NCLBUTTONUP()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_SHOWINFO,OnShowInfo)
	ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyQQDlg message handlers

BOOL CMyQQDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	((CMyQQApp*)AfxGetApp())->m_MainDlg = GetSafeHwnd();     //保存该对话框窗口句柄
	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here

	//把该窗口设置成磁性窗口的主窗口
	MagneticObj.SetMainWinInfo(this->m_hWnd);


	CRect rc;
	GetClientRect(&rc);

	SetCaptionHeight(23);
	SetCaptionButtonRect();

	m_TabCtrlST.CreateEx(WS_EX_TRANSPARENT, NULL, NULL, WS_VISIBLE | WS_CHILD,
		CRect(/*0, 20, rc.Width(), rc.Height()-20*/0,0,0,0 ), this,NULL);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CMyQQDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMyQQDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CPaintDC dc(this); // device context for painting

		CDialog::OnPaint();

		CRect rect;
		GetClientRect(&rect);

		dc.FillSolidRect(rect, RGB(255,255,255));
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMyQQDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

BOOL CMyQQDlg::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
/*	cs.x = cs.y = 0;
	cs.cx = 100;
	cs.cy = 500;
	cs.dwExStyle |= WS_EX_TOPMOST;
*/		
	return CDialog::PreCreateWindow(cs);
}

void CMyQQDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	CRect rc;
	GetClientRect(&rc);	
	
	m_TabCtrlST.MoveWindow(CRect(0, 40, rc.Width(), rc.Height()-40),TRUE);

	SetWindowPos(&wndTopMost,0,0,0,0, SWP_FRAMECHANGED|SWP_NOMOVE|SWP_NOSIZE);
}

void CMyQQDlg::OnNcPaint() 
{
//	CDialog::OnNcPaint();

	CRect wr, cr, titleRc;
	GetWindowRect(&wr);
	GetClientRect(&cr);

	CDC *pDC = this->GetWindowDC();
	

	CDC memDC ,TempDC;
	BITMAP bm;
	CBitmap bitmap, *oldbmp1, *oldbmp2;
	int MBmHeight, LBmHeight, RBmHeight;
	int MBmWidth, LBmWidth, RBmWidth;
	int BotLineHeight;// BotLCorHeight, BotRCorHeight;
	int BotLineWidth; // BotLCorWidth, BotRCorWidth;

	bitmap.CreateCompatibleBitmap(pDC, wr.Width(), wr.Height());
	memDC.CreateCompatibleDC(pDC);
	TempDC.CreateCompatibleDC(pDC);	
	oldbmp2 = TempDC.SelectObject(&bitmap);
	TempDC.FillSolidRect(0,0,wr.Width(), wr.Height(),(COLORREF)::GetSysColor(COLOR_BACKGROUND));


	CBitmap& bmp = m_TabCtrlST.m_pSkin->CapBmMid;
	bmp.GetBitmap(&bm);
	MBmHeight = (int)bm.bmHeight;
	MBmWidth = (int)bm.bmWidth;
	

	CBitmap& capbmplt = m_TabCtrlST.m_pSkin->CapBmLeft;
	capbmplt.GetBitmap(&bm);
	LBmHeight = (int)bm.bmHeight;
	LBmWidth = (int)bm.bmWidth;
	
	CBitmap& capbmprt = m_TabCtrlST.m_pSkin->CapBmRight;
	capbmprt.GetBitmap(&bm);
	RBmHeight = (int)bm.bmHeight;
	RBmWidth = (int)bm.bmWidth;
	

	CBitmap& botbmline = m_TabCtrlST.m_pSkin->BotmBmMidLine;
	botbmline.GetBitmap(&bm);
	BotLineHeight = (int)bm.bmHeight;
	BotLineWidth = (int)bm.bmWidth;

//	CBitmap& botbmlcor = m_TabCtrlST.m_pSkin->BotmBmLCorner;
//	botbmlcor.GetBitmap(&bm);
//	BotLCorHeight = (int)bm.bmHeight;
//	BotLCorWidth = (int)bm.bmWidth;


//	CBitmap& botbmrcor = m_TabCtrlST.m_pSkin->BotmBmRCorner;
//	botbmrcor.GetBitmap(&bm);
//	m_TabCtrlST.m_pSkin->BotmBmRCorner.GetBitmap(&bm);
//	BotRCorHeight = (int)bm.bmHeight;
//	BotRCorWidth = (int)bm.bmWidth;

	
//	pDC->ExcludeClipRect(0, 0, wr.Width(), bm.bmHeight);
//	pDC->SelectClipRgn(NULL);

	//画标题栏	
	oldbmp1 = memDC.SelectObject(&bmp);

	TempDC.StretchBlt(10, 0, wr.Width()-10 , m_cyTitle,
			&memDC, 0, 0, MBmWidth, MBmHeight,SRCCOPY);

	m_TabCtrlST.m_pSkin->DrawTransparent(&TempDC, CPoint(0,0), capbmplt, 
							CPoint(0,0), CSize(LBmWidth, LBmHeight),RGB(0,255,0));

	m_TabCtrlST.m_pSkin->DrawTransparent(&TempDC, CPoint(wr.Width()-RBmWidth, 0), capbmprt, 
							CPoint(0,0), CSize(RBmWidth, RBmHeight),RGB(0,255,0));


	//画标题栏按钮
	SetCaptionButtonRect();
	DrawTitleButton(&TempDC);
	
	//标题栏画完,将它显示出来
	pDC->BitBlt(0, 0, wr.Width(), m_cyTitle, &TempDC, 0,0, SRCCOPY);


	TempDC.SelectObject(oldbmp2);
	TempDC.DeleteDC();
	bitmap.DeleteObject();

	//画边框
	CBitmap& bmpleft = m_TabCtrlST.m_pSkin->sysleftlineBmp;
	CBitmap& bmpright = m_TabCtrlST.m_pSkin->sysrightlineBmp;

	//主窗口左边框
	bmpleft.GetBitmap(&bm);
	memDC.SelectObject(&bmpleft);
	
//	m_TabCtrlST.m_pSkin->sysleftlineBmp.GetBitmap(&bm);
//	memDC.SelectObject(&m_TabCtrlST.m_pSkin->sysleftlineBmp);
	
	pDC->StretchBlt(0, MBmHeight, bm.bmWidth, wr.Height(),&memDC,0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);		
	
	
	//主窗口右边框
	bmpright.GetBitmap(&bm);
	memDC.SelectObject(&bmpright);

//	m_TabCtrlST.m_pSkin->sysrightlineBmp.GetBitmap(&bm);
//	memDC.SelectObject(&m_TabCtrlST.m_pSkin->sysrightlineBmp);

	pDC->StretchBlt(wr.Width() - bm.bmWidth-1, MBmHeight, bm.bmWidth+1, 
			wr.Height(), &memDC,0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);
	
	//画底部
	memDC.SelectObject(&m_TabCtrlST.m_pSkin->BotmBmMidLine);
	pDC->StretchBlt(2, wr.Height()-BotLineHeight-1, wr.Width()-2, BotLineHeight+1,
			&memDC, 0,0, BotLineWidth, BotLineHeight, SRCCOPY);
	
	
	//释放资源	
	memDC.SelectObject(oldbmp1);	
	memDC.DeleteDC();
	
	ReleaseDC(pDC);

	// Do not call CDialog::OnNcPaint() for painting messages
}

LRESULT CMyQQDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CDialog::WindowProc(message, wParam, lParam);
}

void CMyQQDlg::OnMoving(UINT fwSide, LPRECT pRect) 
{
	CDialog::OnMoving(fwSide, pRect);
		
	// TODO: Add your message handler code here
	
	if(pRect ->top < NEAR_SIZE)
	{
		AlignType = ALIGN_TOP;
		pRect->bottom -= pRect->top;
		pRect->top = 0;

		if(pRect->left < NEAR_SIZE)
		{
			AlignType = ALIGN_LEFT;
			pRect->right -= pRect->left;
			pRect->left = 0;
		}
		else if((pRect->right + NEAR_SIZE) > SCREEN_CX)
		{
			AlignType = ALIGN_RIGHT;
			pRect->left += (SCREEN_CX - pRect->right);
			pRect->right = SCREEN_CX;
		}
	}
	else if(pRect->left < NEAR_SIZE)
	{
		AlignType = ALIGN_LEFT;
		pRect->right -= pRect->left;
		pRect->left = 0;
	}
	else if((pRect->right + NEAR_SIZE) > SCREEN_CX)
	{
		AlignType = ALIGN_RIGHT;
		pRect->left += (SCREEN_CX - pRect->right);
		pRect->right = SCREEN_CX;
	}
	else
	{
		AlignType = ALIGN_NONE;
	}



}

void CMyQQDlg::HideWindow(UINT nType, BOOL Flag)
{
	CRect rc;
	GetWindowRect(&rc);
	int i, xoffset=0, yoffset=0;
	int xpos, ypos;
	int nSteps = 2;
	
	switch(nType)
	{
		case ALIGN_TOP:
		{
			//向上移藏
			xoffset = 0;
			xpos = rc.left;
			if (Flag)
			{
				yoffset = -rc.bottom / nSteps;
				ypos = -rc.Height() + APPEAR_SIZE;
			}
			else
			{
				yoffset = -rc.top / nSteps;
				ypos = 0;
			}
			break;
		}
	case ALIGN_LEFT:
		{
			//向左移藏
			yoffset = 0;
			ypos = rc.top;
			if (Flag)
			{
				xoffset = -rc.right / nSteps;
				xpos = -rc.Width() + APPEAR_SIZE;
			}
			else
			{
				xoffset = -rc.left / nSteps;
				xpos = 0;
			}
			break;
		}
	case ALIGN_RIGHT:
		{
			//向右移藏
			yoffset = 0;
			ypos = rc.top;
			if (Flag)
			{
				xoffset = (SCREEN_CX - rc.left) / nSteps;
				xpos = SCREEN_CX - APPEAR_SIZE;
			}
			else
			{
				xoffset = (SCREEN_CX - rc.right) / nSteps;
				xpos = SCREEN_CX - rc.Width();
			}
			break;
		}
	default:
		return;
	}

	for(i=0; i<nSteps; i++)
		{
				rc.left += xoffset;
				rc.top  += yoffset;
				rc.right += xoffset;
				rc.bottom += yoffset;
				MoveWindow(rc.left, rc.top, rc.Width(), rc.Height(), TRUE);
			//	SetWindowPos(NULL, rc.left, rc.top, 0, 0,SWP_NOSIZE | SWP_NOSENDCHANGING);
			//	RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
				Sleep(5);
		}
	
	SetWindowPos(NULL, xpos, ypos, 0, 0, SWP_NOSIZE);

	if (!Flag)	//如果窗体已被显示,设置定时器.监视鼠标.
	{
		SetTimer(WM_TIMER, 50, NULL);
	}	
	
}







void CMyQQDlg::OnNcMouseMove(UINT nHitTest, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	RECT rc;
	GetWindowRect(&rc);

	if(rc.left<0 || rc.top<0 || rc.right>SCREEN_CX )
	{
		HideWindow(AlignType,FALSE);
	}
	else
	{
	//	HideWindow(AlignType,FALSE);
		SetTimer(WM_TIMER,50,NULL);
	}

	if(nHitTest == HTCAPTION)
	{
	//	CRect wr;
		CPoint pt;
	//	GetWindowRect(&wr);
	
		pt.x = point.x - rc.left;
		pt.y = point.y - rc.top;

		if(PtInRect(&m_CapBnRect[0], pt))
		{
			m_MouseState = MS_Hover;
			m_CapBnIndex = 0;
			OnNcPaint();
		}
		else if(PtInRect(&m_CapBnRect[1], pt))
		{
			m_MouseState = MS_Hover;
			m_CapBnIndex = 1;
			OnNcPaint();
		}
		else if(PtInRect(&m_CapBnRect[2], pt))
		{
			m_MouseState = MS_Hover;
			m_CapBnIndex = 2;
			OnNcPaint();
		}
		else
		{
			m_MouseState = MS_Normal;
		}

		//OnNcPaint();
		//SetWindowPos(NULL, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
//		SetCapture();
		OnMouseLeave();
/*		TRACKMOUSEEVENT tme;
		tme.cbSize = sizeof(TRACKMOUSEEVENT);
		tme.dwFlags = TME_LEAVE;
		tme.dwHoverTime = 0;
		tme.hwndTrack = this->m_hWnd;

		::_TrackMouseEvent(&tme);
*/	
	}
	

	CDialog::OnNcMouseMove(nHitTest, point);
}

void CMyQQDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CPoint pt;
	CRect rc;

	GetCursorPos(&pt);
	GetWindowRect(&rc);
	
	if(!rc.PtInRect(pt))
	{
		KillTimer(WM_TIMER);
		HideWindow(AlignType,TRUE);
	}
	CDialog::OnTimer(nIDEvent);
}

void CMyQQDlg::OnShowInfo(LPARAM lParam)
{
	HTREEITEM item = (HTREEITEM)lParam;
	CString str;
	RECT rc;
	GetWindowRect(&rc);

	str = m_TabCtrlST.m_pMainPanel->m_pSTTree->GetItemText(item);

	CUserInfoDlg* pInfoDlg = new CUserInfoDlg;
	pInfoDlg->Create(IDD_INFORMATION,this);
	pInfoDlg->m_ShowText.Format("昵称: %s",str);
	pInfoDlg->UpdateData(FALSE);
//	pInfoDlg->MoveWindow(rc.left-115-10*m_nCount, rc.top+10*m_nCount++, 115, 100,TRUE);
	::SetWindowPos(pInfoDlg->m_hWnd, NULL, rc.left-115-10*m_nCount, rc.top+10*m_nCount++,
		0,0, SWP_NOSIZE);
	pInfoDlg->ShowWindow(SW_SHOW);

	
}



void CMyQQDlg::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	MagneticObj.OnLButtonDown_CriticalSession(this->m_hWnd, point);
	CDialog::OnLButtonDown(nFlags, point);
}

void CMyQQDlg::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	MagneticObj.OnLButtonUp_CriticalSession();
	CDialog::OnLButtonUp(nFlags, point);
}

void CMyQQDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	MagneticObj.OnMouseMove_CriticalSession(point);
	CDialog::OnMouseMove(nFlags, point);
}

BOOL CMyQQDlg::OnNcActivate(BOOL bActive) 
{
	// TODO: Add your message handler code here and/or call default
	m_bActive = bActive;
	OnNcPaint();
	if ( !bActive )
	{
		return 1;
	}
	else
		return 0; 
//	return CDialog::OnNcActivate(bActive);
}

void CMyQQDlg::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) 
{
	// TODO: Add your message handler code here and/or call default
	if ( bCalcValidRects )
	{
		lpncsp->rgrc[0].left = lpncsp->rgrc[0].left - 1;
	//	lpncsp->rgrc[0].right = lpncsp->rgrc[0].right - 4;
	//	lpncsp->rgrc[0].top = lpncsp->rgrc[0].top + 22;
	//	lpncsp->rgrc[0].bottom = lpncsp->rgrc[0].bottom - 22;
		lpncsp->rgrc[1] = lpncsp->rgrc[0];

	}

	CDialog::OnNcCalcSize(bCalcValidRects, lpncsp);
}

void CMyQQDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized) 
{
//	CDialog::OnActivate(nState, pWndOther, bMinimized);
	
	// TODO: Add your message handler code here
//	m_bActive = ( nState == WA_ACTIVE || nState == WA_CLICKACTIVE );
//	OnNcActivate(m_bActive);
}



void CMyQQDlg::SetCaptionButtonRect()
{
	CRect wr;
	GetWindowRect(&wr);

	for(int i = 0; i<3; i++)
	{
		m_CapBnRect[i].left = wr.Width() - 16*(i+1) - i -8;
		m_CapBnRect[i].right = m_CapBnRect[i].left + 16;
		m_CapBnRect[i].top = 3;
		m_CapBnRect[i].bottom = m_CapBnRect[i].top + 16;
	}

}

void CMyQQDlg::SetCaptionHeight(int cy)
{
	m_cyTitle = cy;
}

int CMyQQDlg::GetTitleWidth()
{
	return m_cxTitle;
}

int CMyQQDlg::GetTitleHeight()
{
	return m_cyTitle;	
}

void CMyQQDlg::DrawTitleButton(CDC *pDC)
{

	CBitmap* CapBnBmp[9];
	CapBnBmp[0] = &m_TabCtrlST.m_pSkin->CapBnBmX1;
	CapBnBmp[1] = &m_TabCtrlST.m_pSkin->CapBnBmX2;
	CapBnBmp[2] = &m_TabCtrlST.m_pSkin->CapBnBmX3;
	CapBnBmp[3] = &m_TabCtrlST.m_pSkin->CapBnBmCol1;
	CapBnBmp[4] = &m_TabCtrlST.m_pSkin->CapBnBmCol2;
	CapBnBmp[5] = &m_TabCtrlST.m_pSkin->CapBnBmCol3;
	CapBnBmp[6] = &m_TabCtrlST.m_pSkin->CapBnBmMin1;
	CapBnBmp[7] = &m_TabCtrlST.m_pSkin->CapBnBmMin2;
	CapBnBmp[8] = &m_TabCtrlST.m_pSkin->CapBnBmMin3;

		for(int i = 0; i<3; i++)
		{
			if( m_CapBnIndex != i)
			{
				m_TabCtrlST.m_pSkin->DrawTransparent(pDC,CPoint(m_CapBnRect[i].left,
						m_CapBnRect[i].top), *CapBnBmp[3*i + MS_Normal],
						CPoint(0,0),CSize(m_CapBnRect[i].Width(),
						m_CapBnRect[i].Height()),RGB(255,0,255));
			}
			else
			{
				m_TabCtrlST.m_pSkin->DrawTransparent(pDC,CPoint(m_CapBnRect[m_CapBnIndex].left,
						m_CapBnRect[m_CapBnIndex].top), *CapBnBmp[3*m_CapBnIndex + m_MouseState],
						CPoint(0,0),CSize(m_CapBnRect[m_CapBnIndex].Width(),
						m_CapBnRect[m_CapBnIndex].Height()),RGB(255,0,255));
			}
		}
	
	
}

void CMyQQDlg::OnNcLButtonDown(UINT nHitTest, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(nHitTest == HTCAPTION)
	{
		CRect wr;
		CPoint pt;
		GetWindowRect(&wr);
	
		pt.x = point.x - wr.left;
		pt.y = point.y - wr.top;

		if(PtInRect(&m_CapBnRect[0], pt))
		{
			m_MouseState = MS_LBDown;
			m_CapBnIndex = 0;
		}
		else if(PtInRect(&m_CapBnRect[1], pt))
		{
			m_MouseState = MS_LBDown;
			m_CapBnIndex = 1;
		}
		else if(PtInRect(&m_CapBnRect[2], pt))
		{
			m_MouseState = MS_LBDown;
			m_CapBnIndex = 2;
		}
		else
		{
			m_MouseState = MS_Normal;
		}

		OnNcPaint();
	}

	CDialog::OnNcLButtonDown(nHitTest, point);
}

void CMyQQDlg::OnNcLButtonUp(UINT nHitTest, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
//	GetCapture();
	if(nHitTest == HTCAPTION)
	{
		RECT wr;
		GetWindowRect(&wr);
		point.x -= wr.left;
		point.y -= wr.top;

		if(PtInRect(&m_CapBnRect[0], point))
		{
			OnCloseWindow();
			
		}
		if(PtInRect(&m_CapBnRect[1], point))
		{
			OnColumn();
		}
		if(PtInRect(&m_CapBnRect[2], point))
		{
			OnMinimize();
		}
	}

//	ReleaseCapture();
	CDialog::OnNcLButtonUp(nHitTest, point);
}

void CMyQQDlg::OnMouseLeave()
{
	POINT pt;
	GetCursorPos(&pt);
	CRect wr;
	GetWindowRect(&wr);

	BOOL flag = false;

	pt.x -= wr.left;
	pt.y -= wr.top;

	for(int i = 0; i<3; i++)
	{
		if(PtInRect(&m_CapBnRect[i], pt))
		{
			flag = true;
			break;
		}
	}

	if(!flag)
	{
		m_MouseState = MS_Normal;
		OnNcPaint();
	}

//	ReleaseCapture();
	
}

void CMyQQDlg::OnMinimize()
{
	ShowWindow(SW_MINIMIZE);
	m_MouseState = MS_Normal;
}

void CMyQQDlg::OnColumn()
{

}

void CMyQQDlg::OnCloseWindow()
{
	SendMessage(WM_CLOSE, 0, 0);
}